extends Node2D

var save = true
var items = []

func _ready():
	for i in range(6):
		items.append(get_node("saveItem{index}".format({
			"index": i+1
		})))
		var item:Node2D = items[i]
		item.connect('mouse_click', self, "onItemClick")
	pass
	
func setPage(page):
	# 初始化页面
	var _page = page - 1
	for i in range(items.size()):
		var index = _page * items.size() + i
		items[i].setIndex(index)
	pass
	
func onItemClick(id):
	if save:
		Worker.saveGame(id)
		Worker.saveCommonData()
		items[id%6].setIndex(id)
	else:
		Worker.loadGame(id)
		Model.save.visible = false
		Model.title.visible = false
